/*
 * @lc app=leetcode id=171 lang=cpp
 *
 * [171] Excel Sheet Column Number
 */
class Solution {
public:
    int titleToNumber(string s) {

        int sum = 0;
        int len = s.size();
        if (len < 1) {
            return sum;
        }

        for (auto c : s) {
            if (c < 'A' || c > 'Z') {
                return -1;
            }

            sum = sum * 26 + (c - 'A' + 1);
        }
        return sum;
        
    }
};

